/**
 * SqlMapQueryPage.java : [com.ibader.eclipse.editors.sqlmap] Created on 2009. 5. 29.
 *
 * Copyright (c) 2009 Raccoon Project Team.
 * Seoul, Korea
 * All rights reserved.
 *
 */
package com.ibader.eclipse.editors.sqlmap;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorSite;
import org.eclipse.ui.forms.IManagedForm;
import org.eclipse.ui.forms.editor.FormEditor;
import org.eclipse.ui.forms.widgets.Section;

import com.ibader.eclipse.Activator;
import com.ibader.eclipse.editors.pages.IBaderEditorPage;

/**
 * @author KimJungSu
 * @version
 */
public class SqlMapQueryPage extends IBaderEditorPage {

	private Section selectSection = null;
	private Section insertSection = null;
	private Section updateSection = null;
	private Section deleteSection = null;
	private Section statementSection = null;
	private Section procedureSection = null;
	private Section detailSection = null;

	public SqlMapQueryPage(FormEditor editor, String id, String title) {
		super(editor, id, title);
		// TODO Auto-generated constructor stub
		Activator.log("+++SqlMapQueryPage::Constructor");
		Activator.log("---SqlMapQueryPage::Constructor");
	}

	@Override
	public boolean canLeaveThePage() {
		// TODO Auto-generated method stub
		return super.canLeaveThePage();
	}

	@Override
	public void dispose() {
		// TODO Auto-generated method stub
		super.dispose();
	}

	@Override
	public void doSave(IProgressMonitor monitor) {
		// TODO Auto-generated method stub
		super.doSave(monitor);
	}

	@Override
	public void doSaveAs() {
		// TODO Auto-generated method stub
		super.doSaveAs();
	}

	@Override
	public void init(IEditorSite site, IEditorInput input) {
		// TODO Auto-generated method stub
		super.init(site, input);
	}

	@Override
	public boolean isActive() {
		// TODO Auto-generated method stub
		return super.isActive();
	}

	@Override
	public boolean isDirty() {
		// TODO Auto-generated method stub
		return super.isDirty();
	}

	@Override
	public boolean isEditor() {
		// TODO Auto-generated method stub
		return super.isEditor();
	}

	@Override
	public boolean isSaveAsAllowed() {
		// TODO Auto-generated method stub
		return super.isSaveAsAllowed();
	}

	@Override
	public void setActive(boolean active) {
		// TODO Auto-generated method stub
		super.setActive(active);
	}

	@Override
	public void setFocus() {
		// TODO Auto-generated method stub
		super.setFocus();
	}

	@Override
	public void setIndex(int index) {
		// TODO Auto-generated method stub
		super.setIndex(index);
	}

	@Override
	protected void addContentEventListener() {
		// TODO Auto-generated method stub
		Activator.log("+++SqlMapQueryPage::addContentEventListener");
		Activator.log("---SqlMapQueryPage::addContentEventListener");
	}

	@Override
	protected void createFormContent(IManagedForm managedForm) {
		// TODO Auto-generated method stub
		Activator.log("+++SqlMapQueryPage::createFormContent");

		super.createFormContent(managedForm);

		form.setExpandHorizontal(true);
		form.setExpandVertical(true);
		form.setText("Query");
		form.getBody().setLayout(new FillLayout());

		Composite composite = toolkit.createComposite(form.getBody());
		toolkit.paintBordersFor(composite);
		GridLayout layout = new GridLayout();
		layout.numColumns = 2;
		composite.setLayout(layout);
		composite.setLayoutData(new GridData(SWT.FILL));

		// create contents
		createSelectContent(composite);
		createInsertContent(composite);
		createUpdateContent(composite);
		createDeleteContent(composite);
		createStatementContent(composite);
		createProcedureContent(composite);

		// initialize contents
		initContents();

		// add event listener for contents
		addContentEventListener();

		Activator.log("---SqlMapQueryPage::createFormContent");
	}

	private void createProcedureContent(Composite parent) {
		// TODO Auto-generated method stub

	}

	private void createStatementContent(Composite parent) {
		// TODO Auto-generated method stub

	}

	private void createDeleteContent(Composite parent) {
		// TODO Auto-generated method stub
		Activator.log("+++SqlMapQueryPage::createUpdateContent");

		// create update section from toolkit
		deleteSection = toolkit.createSection(parent,
			Section.DESCRIPTION | Section.TITLE_BAR | Section.EXPANDED);
		deleteSection.setText("Insert");
		deleteSection.setDescription("Insert Query Description");

		// set layout and layout data
		deleteSection.setLayout(new FillLayout());
		GridData gd = new GridData(GridData.FILL);
		deleteSection.setLayoutData(gd);

		// create composite from section with toolkit
		Composite composite = toolkit.createComposite(deleteSection);
		GridLayout layout = new GridLayout();
		layout.numColumns = 2;
		composite.setLayout(layout);

		// set composite to section
		deleteSection.setClient(composite);

		// create controls for section


		Activator.log("---SqlMapQueryPage::createDeleteContent");
	}

	private void createUpdateContent(Composite parent) {
		// TODO Auto-generated method stub
		Activator.log("+++SqlMapQueryPage::createUpdateContent");

		// create update section from toolkit
		updateSection = toolkit.createSection(parent,
				Section.DESCRIPTION | Section.TITLE_BAR | Section.EXPANDED);
		updateSection.setText("Insert");
		updateSection.setDescription("Insert Query Description");

		// set layout and layout data
		updateSection.setLayout(new FillLayout());
		GridData gd = new GridData(GridData.FILL);
		updateSection.setLayoutData(gd);

		// create composite from section with toolkit
		Composite composite = toolkit.createComposite(updateSection);
		GridLayout layout = new GridLayout();
		layout.numColumns = 2;
		composite.setLayout(layout);

		// set composite to section
		updateSection.setClient(composite);

		// create controls for section


		Activator.log("---SqlMapQueryPage::createUpdateContent");
	}

	private void createInsertContent(Composite parent) {
		// TODO Auto-generated method stub
		Activator.log("+++SqlMapQueryPage::createInsertContent");

		// create insert section from toolkit
		insertSection = toolkit.createSection(parent,
				Section.DESCRIPTION | Section.TITLE_BAR | Section.EXPANDED);
		insertSection.setText("Insert");
		insertSection.setDescription("Insert Query Description");

		// set layout and layout data
		insertSection.setLayout(new FillLayout());
		GridData gd = new GridData(GridData.FILL);
		insertSection.setLayoutData(gd);

		// create composite from section with toolkit
		Composite composite = toolkit.createComposite(insertSection);
		GridLayout layout = new GridLayout();
		layout.numColumns = 2;
		composite.setLayout(layout);

		// set composite to section
		insertSection.setClient(composite);

		// create controls for section


		Activator.log("---SqlMapQueryPage::createInsertContent");
	}

	private void createSelectContent(Composite parent) {
		// TODO Auto-generated method stub
		Activator.log("+++SqlMapQueryPage::createSelectContent");

		// create select section from toolkit
		selectSection = toolkit.createSection(parent,
				Section.DESCRIPTION | Section.TITLE_BAR | Section.EXPANDED);
		selectSection.setText("Select");
		selectSection.setDescription("Select Query Description");

		// set layout and layout data
		selectSection.setLayout(new FillLayout());
		GridData gd = new GridData(GridData.FILL);
		selectSection.setLayoutData(gd);

		// create composite from section with toolkit
		Composite composite = toolkit.createComposite(selectSection);
		GridLayout layout = new GridLayout();
		layout.numColumns = 2;
		composite.setLayout(layout);

		// set composite to section
		selectSection.setClient(composite);

		// create controls for section

		Activator.log("---SqlMapQueryPage::createSelectContent");
	}

	@Override
	protected void initContents() {
		// TODO Auto-generated method stub
		Activator.log("+++SqlMapQueryPage::initContents");
		Activator.log("---SqlMapQueryPage::initContents");
	}

	@Override
	public void propertyChange(PropertyChangeEvent event) {
		// TODO Auto-generated method stub
		editor.editorDirtyStateChanged();
	}
}
